<?php
/**
 * Abstract.php
 * @author qqinxl
 * Wed Nov 07 09:11:46 GMT 2007
 * 
 * @category  iQin
 * @package  
 * @copyright  Copyright (c) qqinxl
 */
abstract class Object_Abstract {
	/**
	 * @var Array
	 */
	protected $_row = null;
	
	public function __get($key) {
		if (isset ( $this->_row [$key] )) {
			return $this->_row [$key];
		} else {
			return null;
		}
	}
	
	public function __set($key, $value) {
		if ($key === '_row') {
			$this->setInfo ( $value );
		} else {
			$this->_row [$key] = $value;
		}
	}
	
	public function setInfo($value) {
		if (! is_array ( $value ) and method_exists ( $value, 'toArray' )) {
			$value = $value->toArray ();
		}
		if (is_array ( $value )) {
			$this->_row = $value;
		}
	}
	
	public function getInfo() {
		return $this->_row;
	}
	
	public function isEqual($field, $value) {
		if (! empty ( $this->_row ) and isset ( $this->_row [$field] ) and $this->_row [$field] == $value) {
			return true;
		}
		return false;
	}
	
	public function isMoreThan($field, $value) {
		if (! empty ( $this->_row ) and isset ( $this->_row [$field] ) and $this->_row [$field] >= $value) {
			return true;
		}
		return false;
	}
	public function isLessThan($field, $value) {
		if (! empty ( $this->_row ) and isset ( $this->_row [$field] ) and $this->_row [$field] <= $value) {
			return true;
		}
		return false;
	}
	/**
	 * @param Object_Abstract $object
	 */
	public function copyTo($object){
		if(!$object instanceof Object_Abstract ){
			throw new Exception('Error Pars');
		}
		$object->setInfo($this->getInfo());
		return $object;
	}
}